package top.tagao.multithread_02_use.exercise;

/**
 * @author fu-xiao-liu
 * @Date 2022/3/29 20:19
 *
 * 创建三个窗口卖票，总票数为100张.使用实现Thread接口的方式
 *  存在线程的安全问题，待解决。
 */
public class ex01 {
    public static void main(String[] args) {
        WinThread winThread01 = new WinThread();
        WinThread winThread02 = new WinThread();
        WinThread winThread03 = new WinThread();

        winThread01.start();
        winThread02.start();
        winThread03.start();

    }

}

class WinThread extends Thread {
    static   int ticket = 100;

    @Override
    public void run() {
        while (true) {
            if(ticket > 0){
                System.out.println(Thread.currentThread().getName() + ":卖票，票号为：" + ticket);
                ticket--;
            }else{
                break;
            }
        }
    }
}


